package com.yinda.dt.produce.app;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * 描述
 * <br/>
 * Created by 小灿 on 2017/2/23.
 */

public class DemoConfig {

    private static DemoConfig instance;

    private SharedPreferences preferences;
    private SharedPreferences.Editor editor;

    private DemoConfig(Context context) {
        preferences = context.getSharedPreferences("config", Context.MODE_PRIVATE);
        editor = preferences.edit();
    }

    public static DemoConfig getInstance(Context context) {
        if (instance == null) {
            instance = new DemoConfig(context);
        }
        return instance;
    }

    public void setKey(String key) {
        editor.putString("key", key);
        editor.commit();
    }

    public String getKey() {
        String value = preferences.getString("key", "");
        return value;
    }

    public void setIsLogin(boolean isLogin) {
        editor.putBoolean("isLogin", isLogin);
        editor.commit();
    }

    public boolean isLogin() {
        boolean value = preferences.getBoolean("isLogin", false);
        return value;
    }

    public void setIsPm(String isPm) {
        editor.putString("isPm", isPm);
        editor.commit();
    }

    public String getIsPm() {
        String value = preferences.getString("isPm", "");
        return value;
    }

    public void setUid(String uid) {
        editor.putString("uid", uid);
        editor.commit();
    }

    public String getUid() {
        String value = preferences.getString("uid", "");
        return value;
    }

    public void setAccout(String accout) {
        editor.putString("accout", accout);
        editor.commit();
    }

    public String getAccout() {
        String value = preferences.getString("accout", "");
        return value;
    }

    public void setName(String name) {
        editor.putString("name", name);
        editor.commit();
    }

    public String getName() {
        String value = preferences.getString("name", "");
        return value;
    }


    public void setTel(String tel) {
        editor.putString("tel", tel);
        editor.commit();
    }

    public String getTel() {
        String value = preferences.getString("tel", "");
        return value;
    }

    public void setUserimgUrl(String userimgUrl) {
        editor.putString("userimgUrl", userimgUrl);
        editor.commit();
    }

    public String getUserimgUrl() {
        String value = preferences.getString("userimgUrl", "");
        return value;
    }

    public void setUserimgUpdate(boolean update){
        editor.putBoolean("userimgUpdate", update);
        editor.commit();
    }

    public boolean getUserimgUpdate() {
        boolean value = preferences.getBoolean("userimgUpdate", false);
        return value;
    }

    public void setIsPush(boolean isPush) {
        editor.putBoolean("isPush", isPush);
        editor.commit();
    }

    public boolean isPush() {
        boolean value = preferences.getBoolean("isPush", true);
        return value;
    }

    public void setNewVersionCode(int versionCode) {
        editor.putInt("versionCode", versionCode);
        editor.commit();
    }

    public int getNewVersionCode() {
        int value = preferences.getInt("versionCode", 1);
        return value;
    }

    public void setNewVersionName(String versionName) {
        editor.putString("versionName", versionName);
        editor.commit();
    }

    public String getNewVersionName() {
        String value = preferences.getString("versionName", "1.0.0");
        return value;
    }

    public void setUpdateAppUrl(String updateAppUrl) {
        editor.putString("updateAppUrl", updateAppUrl);
        editor.commit();
    }

    public String getUpdateAppUrl() {
        String value = preferences.getString("updateAppUrl", "");
        return value;
    }

    public String getToken() {
        String value = preferences.getString("token", "");
        return value;
    }

    public void setToken(String token) {
        editor.putString("token", token);
        editor.commit();
    }

}
